package com.quark.controller.system;

import com.quark.model.system.user.LoginModel;
import com.quark.result.RequestResult;
import com.quark.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.Principal;
import java.util.Map;

/**
 * @author 张高昌
 * @date 2021/11/6 11:27
 * @description TODO
 */
@Api(tags = "用户登录模块")
@RestController
@RequiredArgsConstructor
@RequestMapping("/login")
public class LoginController {

    private final UserService userService;

//    @ApiOperation("登录")
//    @PostMapping("/doLogin")
//    public RequestResult doLogin(@RequestBody @Valid LoginModel loginModel, HttpServletRequest req) {
//
//        return RequestResult.success(userService.doLogin(loginModel,req));
//    }

    @ApiOperation("获取信息")
    @PostMapping("info")
    public RequestResult info(Principal principal) {
        Map userInfo = userService.getUserInfo(principal);
        return RequestResult.success(userInfo);
    }
}
